package cn.wolfcode.luowowo.flight.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import cn.wolfcode.luowowo.flight.util.DateUtils;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class AirTicketDetailQuery extends QueryObject {
    public static final int  SCHEDULE_TYPE_ONE = 1;
    public static final int  SCHEDULE_TYPE_DOUBLE = 2;
    private Integer type = SCHEDULE_TYPE_ONE;//默认为1,查询单程
    private String orgCity;//起点
    private String dstCity;//目的地
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private  Date depTime ;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime ;
    //时间区间
    private Integer flytimeType = -1;
    //起飞机场
    private Long beginAirportId = -1L;
    //落地机场
    private Long endAirportId = -1L;
    //航空公司
    private  Long airlinesId = -1L;
    //飞机大小
    private Integer size = -1;

    //排序
    private String orderby = "td.price";


    public String getTypeName(){
        if (type==SCHEDULE_TYPE_ONE){
            return "单程";
        }else{
            return "往返";
        }
    }

    public String getSWeek() {
       return DateUtils.getWeek(depTime);
    }

    public FlightCondition getTime() {
        HashMap<Integer,FlightCondition> FLIGHTTIMEMAP = new HashMap<>();//出发时间映射集
        FLIGHTTIMEMAP.put(-1,null);
        FLIGHTTIMEMAP.put(1,new FlightCondition(DateUtils.getSpecifyTime(depTime,1),DateUtils.getSpecifyTime(depTime,2)));
        FLIGHTTIMEMAP.put(2,new FlightCondition(DateUtils.getSpecifyTime(depTime,3),DateUtils.getSpecifyTime(depTime,4)));
        FLIGHTTIMEMAP.put(3,new FlightCondition(DateUtils.getSpecifyTime(depTime,5),DateUtils.getSpecifyTime(depTime,6)));
        FLIGHTTIMEMAP.put(4,new FlightCondition(DateUtils.getSpecifyTime(depTime,7),DateUtils.getSpecifyTime(depTime,8)));
        FlightCondition flightCondition = FLIGHTTIMEMAP.get(flytimeType);
        return flightCondition;
    }











}
